home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
os2
/
srefv112.zip
/
STATUS.80
< prev
next >
Wrap
Text File
|
1996-05-10
|
6KB
|
155 lines
/* This is the STATUS demo of SRE-FILTER's server side proceessing
Use STATUS.HTM to invoke this routine.
*/
status:
parse arg ddir, tempfile, reqstrg,list,verb ,uri,user, basedir ,workdir,privset,macro_info
list=translate(list, ' ', '+'||'090a0d'x) /* Whitespace, etc. */
/* Information will be returned in a temporary file, whose name
is provided in the tempfile variable.
Note that it's a good idea to start your HTML documents with a dtd doctype statement
*/
call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
call lineout tempfile, "<html><head><title>Results from STATUS request</title>"
call lineout tempfile, "</head><body>"
call lineout tempfile,' <h2>Results from Status Request </h2>'
call lineout tempfile,' <h3>The arguments recieved by STATUS </h3> '
call lineout tempfile,' <dl> '
call lineout tempfile,' <dt> DDIR = <code>' ddir '</code> '
call lineout tempfile,' <dd> The "data directory" (where your HTML documents should be) '
call lineout tempfile,' <dt> TEMPFILE = <code>' tempfile ' </code> '
call lineout tempfile,' <dd> The "temporary file" (used to build this response)'
call lineout tempfile,' <dt> REQSTRG = <code>' reqstrg ' </code> '
call lineout tempfile,' <dd> The request string '
call lineout tempfile,' <dt> LIST = <code>' list ' </code> '
call lineout tempfile,' <dd> The parameters: '
call lineout tempfile, '<br> ... if POST method, from the "body" of the request '
call lineout tempfile,' <br> ... if GET method , from after the "?" in the request string. '
call lineout tempfile,' <dt> VERB = <code>' VERB ' </code> '
call lineout tempfile,' <dd> The HTTP method '
call lineout tempfile,' <dt> URI = <code>' URI ' </code> '
call lineout tempfile,' <dd> The full URI '
call lineout tempfile,' <dt> USER = <code>' user ' </code> '
call lineout tempfile,' <dd> USERS ip addrees '
call lineout tempfile,' <dt> BASEDIR = <code>' basedir ' </code> '
call lineout tempfile,' <dd> The "working directory" (where SRE-FILTER and GoServe live) '
call lineout tempfile,' <dt> WORKDIR = <code>' workdir ' </code> '
call lineout tempfile,' <dd> Temporary working files area '
call lineout tempfile,'</dl>'
/* Read the "header" -- and display the results */
'READ HEADER VAR FOO '
call lineout tempfile,' <h3> The Request Header </h3> '
call lineout tempfile,' <dd> <blockquote> <pre>' foo '</pre> </blockquote>'
call lineout tempfile,' <h3> Some User & Server Info </h3> '
/* This section demonstrates the use of some GOSERVE functions */
cname=clientname()
caddr=extract('CLIENTADDR')
ssoft=server()
sname=servername()
saddr=extract('SERVERADDR')
sport=extract('SERVERPORT')
call lineout tempfile,' <ul> '
call lineout tempfile,' <li> Client ip address: <code>' caddr '</code>'
call lineout tempfile,' <li> Client name: <code>' cname '</code>'
call lineout tempfile,' <li> Server ip address: <code>' saddr '</code>'
call lineout tempfile,' <li> Server port: <code>' sport '</code>'
call lineout tempfile,' <li> Server name: <code>' sname '</code>'
call lineout tempfile, ' <li> Server software: <code>' ssoft '</code>'
call lineout tempfile,' <li> Your privileges are: <tt> ' privset ' </tt>'
call lineout tempfile,' </ul> '
/* superusers and inhouse users get to see sre-filter's parameters,
if desired (by pressing a link to filtinst */
if wordpos('SUPERUSER',privset)=0 then signal getuse
call lineout tempfile,' <h3> SRE-FILTER settings </h3> '
call lineout tempfile,' <br> Do you want to see the <A href='
call lineout tempfile,' "/filtinst?todo=show">current settings of SRE-FILTER'"'s parameters</A>? <br>"
getuse: nop
/* get some "intensity of use " statistics */
reptime=extract('RESPONSETIME')
numtrans=extract('TRANSACTIONS')
whenstart=extract('LASTSTART')
nclients=extract('CLIENTS')
call lineout tempfile,' <h3> Use Statistics </h3> '
call lineout tempfile,'<BR> GoServe started: ' whenstart
call lineout tempfile,'<BR> # of transactions ' numtrans ', avg. reponsetime = 'reptime ' sec. '
call lineout tempfile,'<BR> Current # of clients = ' nclients
/* Use the HOST function -- demonstrates the use of external calls */
/* but first "parse" the parameter list, and store in a simple stem variable */
m=0
do until list=""
parse var list opt1 '&' list
m=m+1
parse var opt1 optname.m '=' optvalue.m
end
optname.0=m
/* see if one of the opts is "getip" */
chkip=0 ;
do mm=1 to optname.0
if translate(optname.mm)='GETIP' then do
chkip=optvalue.mm
leave
end
end
/* if we found a GETIP, and got it's value, then lookit up */
if chkip<>0 & chkip<>"" then do
/* Note use of the address cmd xxx to call a OS/2 level command */
do queued(); pull .; end /* flush */
address cmd '@host' chkip '| rxqueue' /* execute the command */
parse pull hostresult /* get result */
call lineout tempfile,' <h3> Look up address </h3> '
call lineout tempfile,' <pre> ' hostresult ' </pre>'
end
/* all done, write final end-of-html elements */
call lineout tempfile,'<body> </html>'
/* Return a "completion code" -- SRE-FILTER will do the rest */
/* Note: a VAR (and sometimes a STRING) completion code
is often used instead of FILE .. TEMPFILE */
return 'FILE ERASE TYPE text/html NAME' tempfile